package com.jifeng.sterilizer.uaa.utils;

import com.jifeng.sterilizer.uaa.utils.msg.IErrorCodeMessage;
import com.jifeng.sterilizer.uaa.utils.msg.IErrorMessage;
import com.jifeng.sterilizer.uaa.utils.msg.IResult;

/**
 * @author huss
 */
public class Results implements IResult {

    @Override
    public Result failure(IErrorMessage message) {
        Integer errorCode = 400;
        String errorMsg = "失败！";
        if (message != null && message instanceof IErrorCodeMessage) {
            errorCode = ((IErrorCodeMessage)message).getErrorCode();
            errorMsg = message.getErrorMsg();

        }
        return new Result(errorCode, errorMsg, null);
    }

    @Override
    public Result failure() {
        return failure(null);
    }

    @Override
    public Result success() {
        return success(null);
    }

    @Override
    public Result success(Object data) {
        return new Result(200, "成功！", data);
    }

}
